/*
 * lcd-api.h
 *
 *  Created on: 2010/04/09
 *      Author: debian
 */

#ifndef LCDAPI_H_
#define LCDAPI_H_

#ifdef __USE_CMSIS
#include "LPC11xx.h"
#endif






/*------- LCD control port --------*/
/*use port3 for lcd control port*/
#define LCD_CONTROL_PORT PORT3
/* lcd chip select pin*/
#define LCD_CS 0
/* lcd write pin */
#define LCD_WR 1
/* lcd reset pin*/
#define LCD_RS 2
/* lcd read pin */
#define LCD_RD 3

/*------- LCD data port -------*/
/*
 *  1. LCD DB0 to DB11 pins are connected with LPC1114 PIO2_0 to PIO2_11
 *  2. LCD DB12 to DB15 are connected with LPC1114 PIO1_0 to PIO1_3
 *
 */
#define LCD_DATA_LOW_PORT PORT2
#define LCD_DATA_LOW_PORT_MSB (11)
#define LCD_DATA_LOW_PORT_LSB (0)
#define LCD_DATA_HIGH_PORT PORT1
#define LCD_DATA_HIGH_PORT_MSB (3)
#define LCD_DATA_HIGH_PORT_LSB (0)


//#define red			(0xf800)
#define red         (0x001F)
//#define green		(0x07e0)
#define green       (0x7c00)
//#define blue		(0x001f)
#define blue        (0x03e0)
#define black		(0x0000)
#define white		(0xffff)
#define gray		(0x8c51)
#define yellow		(0xFFE0)
#define cyan		(0x07FF)
#define purple		(0xF81F)

//maximum lcd width (pixel)
#define MAX_WIDTH (240)
//maximum lcd width (pixel)
#define MAX_HEIGHT (320)

/*========= Font number 5x7 pixel=========*/
//font width max (pixel)
#define FONT_WIDTH (5)

//font height max (pixel)
#define FONT_HEIGHT (7)

static uint16_t colorc[]={red,green,blue,black,white,gray,yellow,cyan,purple};

#define TIMER1 (1) //using timer 1 for delay

void init_LCD(void);
void Display(uint16_t c1,uint16_t x,uint16_t y);

void Delayms(uint16_t i);
void Delay(uint16_t i);

/*draw rectangle function*/
void DrawRectangle(uint16_t color,
				   uint16_t x,uint16_t y,
				   uint16_t width,uint16_t hight,
				   uint16_t line_width);
/*fill rectangle */
void FillRectangle(uint16_t  color,
		   uint16_t x,uint16_t y,
		   uint16_t width,uint16_t height);
/*draw image */
void DrawImage(uint16_t pixelcolor[],
		   uint16_t x,uint16_t y,
		   uint16_t width,uint16_t height,uint8_t rotate);
/*draw number 0-9*/
uint8_t DrawNumber(uint16_t color,uint16_t x,uint16_t y,uint8_t value,uint8_t backg,uint8_t rotate);

/* read pixel color from coor */
uint16_t ReadPixel(uint16_t x,uint16_t y);

#endif /* LCDAPI_H_ */
